import { defineConfig } from 'vite' // 动态配置函数
import { createVuePlugin } from 'vite-plugin-vue2'
import image from "@rollup/plugin-image"
import path from 'path' // 需安装此模块
import alias from "@rollup/plugin-alias";
export default () =>
	defineConfig({
		plugins: [createVuePlugin(), image(), alias()],
		server: {
			open: true, //自动打开浏览器
			port: 8081, //端口号
			hmr: true, //热更新
			proxy: {
				'/api': {
					target: 'http://lemonstudy.natapp1.cc/api',
					changeOrigin: true,
					rewrite: path => path.replace(/^\/api/, '')
				}
			}
		},
		resolve: {
			extensions: [".vue", ".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
			// 别名
			alias: {
				'@': path.resolve(__dirname, './src')
			}
		},
	})
